*------------- Upper-Body Strength and Political Egalitarianism: Twelve Conceptual Replications ------------------------------------*
*----------------------------------------------------- STUDY 10 ---------------------------------------------------------------------*

*** Recodes central variables

* Creates education variable
ta Q25_P1
gen edu= Q25_P1

* Creates sex variable
gen female = Q24_P1
recode female (1=0) (2=1)

*** Creates SDO scale
recode Q11_2_P2 Q11_4_P2 Q11_5_P2 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1), gen ( Q11_2_P2n Q11_4_P2n Q11_5_P2n)
alpha Q11_1_P2 Q11_3_P2 Q11_6_P2 Q11_2_P2n Q11_4_P2n Q11_5_P2n
egen SDO=rmean( Q11_1_P2 Q11_3_P2 Q11_6_P2 Q11_2_P2n Q11_4_P2n Q11_5_P2n)
ta SDO

** Recodes SDO variable to a 0-1 scale for observed min and max for males and females, respectively
* Females
summ SDO if female == 1
generate SDO01 = (SDO-(r(min)))/(r(max)-r(min)) if female == 1

* Males
summ SDO if female == 0
replace SDO01 = (SDO-(r(min)))/(r(max)-r(min)) if female == 0
summ SDO01


*** Creates RWA scale
recode Q12_1_P2 Q12_3_P2 Q12_4_P2 Q12_5_P2 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1), gen ( Q12_1_P2n Q12_3_P2n Q12_4_P2n Q12_5_P2n)
alpha Q12_2_P2 Q12_6_P2 Q12_1_P2n Q12_3_P2n Q12_4_P2n Q12_5_P2n
egen RWA=rmean ( Q12_2_P2 Q12_6_P2 Q12_1_P2n Q12_3_P2n Q12_4_P2n Q12_5_P2n)

*Recodes to a 0-1 scale for observed min and max within sex
summ RWA if female == 1
generate RWA01 = (RWA-(r(min)))/(r(max)-r(min)) if female == 1

summ RWA if female == 0
replace RWA01 = (RWA-(r(min)))/(r(max)-r(min)) if female == 0
summ RWA01


*** Creates Economic conservatism scale
recode Q16_1_P2 Q16_5_P2 Q16_6_P2 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1), gen(Q16_1_P2n Q16_5_P2n Q16_6_P2n)
alpha Q16_1_P2n Q16_2_P2 Q16_3_P2 Q16_4_P2 Q16_5_P2n Q16_6_P2n
egen econideox =rmean (Q16_1_P2n Q16_2_P2 Q16_3_P2 Q16_4_P2 Q16_5_P2n Q16_6_P2n)
sum econideox

*** Recodes to a 0-1 scale for observed min and max for males and females, respectively
* Females
summ econideox if female == 1
generate econideo01 = (econideox-(r(min)))/(r(max)-r(min)) if female == 1

* Males
summ econideox if female == 0
replace econideo01 = (econideox-(r(min)))/(r(max)-r(min)) if female == 0
 

*** Ceates Physical Strength Variable
* Uses largest of two handgrip strength trials
gen maxstyrke=Hndgreb1
replace maxstyrke=Hndgreb2 if Hndgreb2>Hndgreb1
ta maxstyrke

*** Recodes to a 0-1 scale for observed min and max for males and females, respectively
* Females
summ maxstyrke if female == 1
generate strength01 = (maxstyrke-(r(min)))/(r(max)-r(min)) if female == 1

*Males
summ maxstyrke if female == 0
replace strength01 = (maxstyrke-(r(min)))/(r(max)-r(min)) if female == 0


*** Creates scale for self-reported current living conditions (adult socio-economic-status)
alpha Q3_1_P1 Q3_2_P1 Q3_3_P1, gen(adultses)

*** Recodes to a 0-1 scale for observed min and max for males and females, respectively
* Females
sum adultses if female == 1
generate adultses01 = (adultses-(r(min)))/(r(max)-r(min)) if female == 1

* Males
sum adultses if female == 0
replace adultses01 = (adultses-(r(min)))/(r(max)-r(min)) if female == 0

bys female: summ adultses01


*--------------------------------------------------------- ANALYSES -----------------------------------------------------*

* Descriptives
tab female if age !=.
summ age

//Formidability
bys female: summ strength01 if age !=.

//SDO
alpha Q11_1_P2 Q11_3_P2 Q11_6_P2 Q11_2_P2n Q11_4_P2n Q11_5_P2n if age !=.
bys female: summ SDO01 if age !=.

//Economic Cons
alpha Q16_1_P2 Q16_2_P2 Q16_3_P2 Q16_4_P2 Q16_5_P2 Q16_6_P2 if age !=.
bys female: sum econideo01 if age !=.

//RWA
alpha Q12_2_P2 Q12_6_P2 Q12_1_P2n Q12_3_P2n Q12_4_P2n Q12_5_P2n if age !=.
bys female: summ RWA01 if age !=.


****** Does physical strength predict SDO?
* Females
reg SDO01 strength01 age if female==0

* Males
reg SDO01 strength01 age if female==1


****** Does physical strength predict RWA?
* Females
reg RWA01 strength01 age if female==0

* Males
reg RWA01 strength01 age if female==1


****** Does physical strength predict economic conservatism?
* Females
reg econideo01 strength01 age if female==0

* Males
reg econideo01 strength01 age if female==1



***** Mediation analyses: Does physical strength predict economic conservatism through SDO?
* FEMALES
sem (age strength01 -> SDO01) ///
(age strength01 SDO01 -> econideo01) if female==1, nocapslatent 
estat teffects
estat gof, stats(all)

* MALES
sem (age strength01 -> SDO01) ///
(age strength01 SDO01 -> econideo01) if female==0, nocapslatent 
estat teffects
estat gof, stats(all)


***** Does current living conditions (adult SES) moderate the relationship between physical strength and SDO or economic conservatism?
*** Models predicting SDO
* Female subjects
reg SDO01 c.strength01##c.adultses01 age if female==1

margins, dydx(strength01) at(adultses01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of Strength) title("") scheme(s2mono)

* Male subjects
reg SDO01 c.strength01##c.adultses01 age if female==0

margins, dydx(strength01) at(adultses01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of Strength) title("") scheme(s2mono)


*** Models predicting economic conservatism
* Females
reg econideo01 c.strength01##c.adultses01 age if female==1

margins, dydx(strength01) at(adultses01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of Strength) title("") scheme(s2mono)

* Males
reg econideo01 c.strength01##c.adultses01 age if female==0

margins, dydx(strength01) at(adultses01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of Strength) title("") scheme(s2mono)
